/* 
 * File:   message_builder.h
 * Author: james
 *
 * Created on 2011年3月31日, 下午1:45
 */

#ifndef MESSAGE_BUILDER_H
#define	MESSAGE_BUILDER_H

#include "message.h"
#include "log.h"

namespace edm
{
    namespace network
    {
        class message_builder_t
        {
        public:
            static int build_header(message_header_t& hdr, void* buffer, unsigned int len)
            {
                logtrace((MYNET, "message_builder_t::build_header begin ..."));
                if(len < sizeof(message_header_t))
                {
                    logerror((MYNET, "message_builder_t::build_header buffer size too small."));
                    return -1;
                }              
                //!TODO:: hton transfer
                memcpy(buffer, &hdr, sizeof(message_header_t));
                
                logtrace((MYNET, "message_builder_t::build_header begin end ok."));
                return 0;
            }
        };       
    }
}

#endif	/* MESSAGE_BUILDER_H */

